package com.eastfair.imaster.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 业务资源表
 * </p>
 *
 * @author ligang
 * @date 2022-03-10
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "BusinResourceResourceTypeEnum", description = "资源类型#{news:新闻;video:视频;data:资料-枚举")
public enum BusinResourceResourceTypeEnum implements BaseEnum {

    /**
     * NEWS="新闻"
     */
    NEWS("新闻"),
    /**
     * VIDEO="视频"
     */
    VIDEO("视频"),
    /**
     * DATA="资料"
     */
    DATA("资料"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static BusinResourceResourceTypeEnum match(String val, BusinResourceResourceTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static BusinResourceResourceTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(BusinResourceResourceTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "NEWS,VIDEO,DATA", example = "NEWS")
    public String getCode() {
        return this.name();
    }

}
